package br.com.wagnerpaz.javahook.win32.jna;

import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;

/**
 * Provides partial access to the w32 user32 library.
 */
public interface User32 extends W32API
{
	User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class, DEFAULT_OPTIONS);
	
	//VIRTUAL KEYS
	int VK_SHIFT    = 16;
	int VK_LSHIFT   = 0xA0;
	int VK_RSHIFT   = 0xA1;
	int VK_CONTROL  = 17;
	int VK_LCONTROL = 0xA2;
	int VK_RCONTROL = 0xA3;
	int VK_MENU     = 18;
	int VK_LMENU    = 0xA4;
	int VK_RMENU    = 0xA5;
	
	//HOOK TYPES
	int WH_KEYBOARD    = 2;
	int WH_MOUSE       = 7;
	int WH_KEYBOARD_LL = 13;
	int WH_MOUSE_LL    = 14;
	
	//KEY EVENT TYPES
	int WM_KEYDOWN    = 256;
	int WM_KEYUP      = 257;
	int WM_SYSKEYDOWN = 260;
	int WM_SYSKEYUP   = 261;
	
	//MOUSE EVENT TYPES
	int WM_MOUSEMOVE   = 512;
	int WM_LBUTTONDOWN = 513;
	int WM_LBUTTONUP   = 514;
	int WM_RBUTTONDOWN = 516;
	int WM_RBUTTONUP   = 517;
	int WM_MBUTTONDOWN = 519;
	int WM_MBUTTONUP   = 520;
	int WM_MOUSEWHEEL  = 522;

	class POINT extends Structure
	{
		public int x;
		public int y;

		public POINT()
		{
		}

		public POINT(int x, int y)
		{
			this.x = x;
			this.y = y;
		}
	}
	
	class KBDLLHOOKSTRUCT extends Structure
	{
		public int vkCode;
		public int scanCode;
		public int flags;
		public int time;
		public ULONG_PTR dwExtraInfo;
	}
	
	class MSLLHOOKSTRUCT extends Structure
	{
		public POINT pt;
		public HWND  hwnd;
		public int   wHitTestCode;
		public ULONG_PTR dwExtraInfo;
	}
	
	class MSG extends Structure
	{
		public HWND   hWnd;
		public int    message;
		public WPARAM wParam;
		public LPARAM lParam;
		public int    time;
		public POINT  pt;
	}

	class HHOOK extends HANDLE
	{
		
	}

	interface HOOKPROC extends StdCallCallback
	{
		
	}
	
	interface LowLevelKeyboardProc extends HOOKPROC
	{
		LRESULT callback(int nCode, WPARAM wParam, KBDLLHOOKSTRUCT lParam);
	}
	
	interface LowLevelMouseProc extends HOOKPROC
	{
		LRESULT callback(int nCode, WPARAM wParam, MSLLHOOKSTRUCT lParam);
	}

	HHOOK SetWindowsHookEx(int idHook, HOOKPROC lpfn, HINSTANCE hMod, int dwThreadId);
	LRESULT CallNextHookEx(HHOOK hhk, int nCode, WPARAM wParam, LPARAM lParam);
	LRESULT CallNextHookEx(HHOOK hhk, int nCode, WPARAM wParam, Pointer lParam);
	boolean UnhookWindowsHookEx(HHOOK hhk);
	
	int GetMessage(MSG lpMsg, HWND hWnd, int wMsgFilterMin, int wMsgFilterMax);
	boolean PeekMessage(MSG lpMsg, HWND hWnd, int wMsgFilterMin, int wMsgFilterMax, int wRemoveMsg);
	boolean TranslateMessage(MSG lpMsg);
	LRESULT DispatchMessage(MSG lpMsg);
	void PostMessage(HWND hWnd, int msg, WPARAM wParam, LPARAM lParam);
	void PostQuitMessage(int nExitCode);
}